home *** CD-ROM | disk | FTP | other *** search
- unit Ufmgr6;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, ShellAPI, FileCtrl,
- DRWSUtl1, DRWSUtl2;
-
- type
- TCCFileMgrForm = class(TForm)
- Panel1: TPanel;
- Panel2: TPanel;
- BitBtn1: TBitBtn;
- Panel3: TPanel;
- Label1: TLabel;
- BitBtn2: TBitBtn;
- BitBtn3: TBitBtn;
- BitBtn4: TBitBtn;
- BitBtn5: TBitBtn;
- BitBtn6: TBitBtn;
- BitBtn7: TBitBtn;
- OpenDialog1: TOpenDialog;
- BitBtn8: TBitBtn;
- BitBtn9: TBitBtn;
- OpenDialog2: TOpenDialog;
- procedure FormResize(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure BitBtn7Click(Sender: TObject);
- procedure BitBtn1Click(Sender: TObject);
- procedure BitBtn2Click(Sender: TObject);
- procedure BitBtn3Click(Sender: TObject);
- procedure BitBtn4Click(Sender: TObject);
- procedure BitBtn5Click(Sender: TObject);
- procedure DirectoryListBox1Change(Sender: TObject);
- procedure FormPaint(Sender: TObject);
- procedure FileListBox1DblClick(Sender: TObject);
- procedure BitBtn8Click(Sender: TObject);
- procedure BitBtn9Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- DirectoryListBox1 : TDirectoryListBox;
- FileListBox1 : TIconFileListBox;
- ScrollBox1 : TFileIconPanelScrollbox;
- end;
- var
- CCFileMgrForm : TCCFileMgrForm;
- CurrentView : Integer; { This holds the current view setting }
-
- implementation
-
- {$R *.DFM}
-
- uses DDDFUnit; { Include custom directory selection form }
-
- { Set up the resize to replace the icon buttons }
- procedure TCCFileMgrForm.FormResize(Sender: TObject);
- begin
- { Send in the panel and global buttons list }
- SpacePanelButtons( Panel2 );
- end;
-
- { Delphi wrote this; use it to set everything up }
- procedure TCCFileMgrForm.FormCreate(Sender: TObject);
- var TheIconPanel : TFileIconPanel;
- CurrentPath : String;
- begin
- { Create the directory list box }
- DirectoryListBox1 := TDirectoryListBox.Create( Panel1 );
- DirectoryListBox1.Parent := Panel1;
- DirectoryListBox1.Visible := true;
- DirectoryListbox1.Top := 17;
- DirectoryListbox1.Left := 0;
- DirectoryListbox1.Height := Panel1.Height - 32;
- DirectoryListbox1.Width := 0;
- { Create the file list box }
- FileListBox1 := TIconFileListBox.Create( Panel1 );
- FileListBox1.Parent := Panel1;
- FileListbox1.Top := 17;
- FileListbox1.Left := 146;
- FileListbox1.Height := Panel1.Height - 32;
- FileListbox1.Width := 0;
- FileListBox1.Visible := true;
- FileListBox1.ShowGlyphs := true;
- { Set intercomponent interactions }
- DirectoryListBox1.FileList := FileListbox1;
- DirectoryListBox1.DirLabel := Label1;
- { Create the scrollbox }
- ScrollBox1 := TFileIconPanelScrollBox.Create( Panel1 );
- ScrollBox1.Parent := Panel1;
- ScrollBox1.align := alClient;
- ScrollBox1.Left := 0;
- ScrollBox1.Top := 0;
- ScrollBox1.Width := Panel1.Width - 32;
- ScrollBox1.Height := Panel1.Height - 32;
- ScrollBox1.IconsNeedRefreshing := false;
- ScrollBox1.TheStoredHandle := Self.Handle;
- { Get the current directory with 0 parameter }
- GetDir( 0 , CurrentPath );
- { Set the display caption }
- Label1.Caption := CurrentPath;
- { Add a trailing \ if not root }
- CurrentPath := ScrollBox1.TheFWB.ForceTrailingBackSlash( CurrentPath );
- { Get the icons display using scrollbox1 }
- ScrollBox1.GetIconsForEntireDirectory( CurrentPath );
- { Set the Icon View as default }
- CurrentView := 1;
- end;
-
- { Delphi wrote this; use it to close the application }
- procedure TCCFileMgrForm.BitBtn7Click(Sender: TObject);
- begin
- Close;
- end;
-
- { Delphi wrote this use it to perform a copy on all selected files }
- procedure TCCFileMgrForm.BitBtn1Click(Sender: TObject);
- var ThePosition : Integer; { Loop counter }
- CurrentName , { Holds work name}
- TheOldString : String; { Holds Dir }
- finished : Boolean; { Loop control }
- WorkingDir : String; { Holds mod wd }
- TargetDir : String; { target of op }
- TheResult : Integer; { Modal res hold }
- begin
- { Get current directory and save it for later }
- GetDir( 0 , TheOldString );
- { Check for need to add trailing \ }
- WorkingDir := TheOldString;
- WorkingDir := ScrollBox1.TheFWB.ForceTrailingBackSlash( WorkingDir );
- { Display the Windows-based directory input form }
- TheResult := DestDDForm.ShowModal;
- { If not cancelled do the copy }
- if TheResult = mrOK then
- begin
- { Get the target directory with \ OK }
- TargetDir := DestDDForm.GetTargetDirectory;
- { Show the hourglass to indicate waiting }
- Screen.Cursor := crHourGlass;
- { Setup to get all selections }
- ThePosition := 1;
- finished := false;
- while not finished do
- begin
- { Call generic file getting routine based on current view}
- case CurrentView of
- 1 : CurrentName := ScrollBox1.GetNextSelection( WorkingDir ,
- ThePosition );
- 2 : CurrentName := FileListBox1.GetNextSelection( WorkingDir ,
- ThePosition );
- end;
- { If returns blank string out of selections so exit }
- if CurrentName = '' then finished := true else
- begin
- { If a directory signal error }
- if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
- begin
- if MessageDlg( 'Copy Directory ' + CurrentName + ' to ' + TargetDir
- +'?', mtConfirmation , mbYesNoCancel , 0 ) = mryes then
- begin
- ScrollBox1.TheFWB.RecursivelyCopyDirectory( CurrentName ,
- TargetDir );
- end;
- end
- else
- begin
- Scrollbox1.TheFWB.CopyTheFile( CurrentName , TargetDir );
- end;
- end;
- end;
- { Reset to normal cursor }
- Screen.Cursor := crDefault;
- end;
- { Reset to the original directory }
- ChDir( TheOldString );
- end;
-
- { Delphi wrote this, use it to move files which are selected }
- procedure TCCFileMgrForm.BitBtn2Click(Sender: TObject);
- var ThePosition : Integer; { Loop counter }
- CurrentName , { Holds work name}
- TheOldString : String; { Holds Dir }
- finished : Boolean; { Loop control }
- WorkingDir : String; { Holds mod wd }
- TargetDir : String; { target of op }
- TheResult : Integer; { Modal res hold }
- begin
- { Get current directory and save it for later }
- GetDir( 0 , TheOldString );
- { Check for need to add trailing \ }
- WorkingDir := TheOldString;
- WorkingDir := ScrollBox1.TheFWB.ForceTrailingBackSlash( WorkingDIr );
- { Display the Windows-based directory input form }
- TheResult := DestDDForm.ShowModal;
- { If not cancelled do the copy }
- if TheResult = mrOK then
- begin
- { Get the target directory with \ OK }
- TargetDir := DestDDForm.GetTargetDirectory;
- { Show the hourglass to indicate waiting }
- Screen.Cursor := crHourGlass;
- { Set up to get all current selections }
- ThePosition := 1;
- finished := false;
- while not finished do
- begin
- { Call generic file getting routine based on current view}
- case CurrentView of
- 1 : CurrentName := ScrollBox1.GetNextSelection( WorkingDir ,
- ThePosition );
- 2 : CurrentName := FileListBox1.GetNextSelection( WorkingDir ,
- ThePosition );
- end;
- { If returns blank string then out of selections }
- if CurrentName = '' then finished := true else
- begin
- { If a directory signal error }
- if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
- begin
- if MessageDlg( 'Move Directory ' + CurrentName + ' to ' + TargetDir +
- '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
- ScrollBox1.TheFWB.RecursivelyMoveDirectory( CurrentName ,
- TargetDir );
- end
- else
- begin
- Scrollbox1.TheFWB.MoveTheFile( CurrentName , TargetDir );
- end;
- end;
- { Reset to normal cursor }
- Screen.Cursor := crDefault;
- end;
- end;
- { Reset to the original directory }
- ChDir( TheOldString );
- if CurrentView = 1 then { Reset icon display if in view }
- ScrollBox1.Update else FileListBox1.Update; { Otherwise update the FLB }
- end;
-
- { Delphi wrote this, use it to delete files which are selected }
- procedure TCCFileMgrForm.BitBtn3Click(Sender: TObject);
- var ThePosition : Integer; { Loop counter }
- CurrentName , { Holds work name}
- TheOldString : String; { Holds Dir }
- finished : Boolean; { Loop control }
- WorkingDir : String; { Holds mod wd }
- begin
- { Get current directory and save it for later }
- GetDir( 0 , TheOldString );
- { Check for need to add trailing \ }
- WorkingDir := TheOldString;
- WorkingDir := ScrollBox1.TheFWB.ForceTrailingBackSlash( WorkingDIr );
- { Set up to do loop for selected files }
- ThePosition := 1;
- finished := false;
- while not finished do
- begin
- { Call generic file getting routine based on current view}
- case CurrentView of
- 1 : CurrentName := ScrollBox1.GetNextSelection( WorkingDir ,
- ThePosition );
- 2 : CurrentName := FileListBox1.GetNextSelection( WorkingDir ,
- ThePosition );
- end;
- { if returns blank string out of selections }
- if CurrentName = '' then finished := true else
- begin
- { If its a directory signal error }
- if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
- begin
- if MessageDlg( 'Delete Directory ' + CurrentName + '?' , mtConfirmation,
- mbYesNoCancel , 0 ) = mrYes then
- begin
- ScrollBox1.TheFWB.RecursivelyDeleteDirectory( CurrentName );
- Scrollbox1.TheFWB.RemoveDirectory( Currentname );
- end;
- end
- else
- begin
- { Otherwise get confirmation message and if OKed delete file }
- if MessageDlg( 'Delete file ' + CurrentName + '?', mtConfirmation ,
- mbYesNoCancel , 0 ) = mrYes then
- begin
- ScrollBox1.TheFWB.DeleteTheFile( Currentname );
- end;
- end;
- end;
- end;
- if CurrentView = 1 then { Reset icon display if in view }
- ScrollBox1.Update else FileListBox1.Update; { Otherwise update the FLB }
- end;
-
- { Delphi wrote this; use it to rename selected files }
- procedure TCCFileMgrForm.BitBtn4Click(Sender: TObject);
- var ThePosition : Integer; { Loop counter }
- CurrentName , { Holds work name}
- TheOldString : String; { Holds Dir }
- finished : Boolean; { Loop control }
- WorkingDir : String; { Holds mod wd }
- begin
- { Get current directory for later }
- GetDir( 0 , TheOldString );
- { Check for need to add trailing \ }
- WorkingDir := TheOldString;
- WorkingDir := ScrollBox1.TheFWB.ForceTrailingBackSlash( WorkingDIr );
- { Set up to do loop for selected files }
- ThePosition := 1;
- finished := false;
- while not finished do
- begin
- { Call generic file getting routine based on current view}
- case CurrentView of
- 1 : CurrentName := ScrollBox1.GetNextSelection( WorkingDir ,
- ThePosition );
- 2 : CurrentName := FileListBox1.GetNextSelection( WorkingDir ,
- ThePosition );
- end;
- { If returns blank string then out of selections }
- if CurrentName = '' then finished := true else
- begin
- { Otherwise set up the opendialog with filename and caption }
- OpenDialog1.Filename := ExtractFilename( CurrentName );
- { Use this to prevent error from changing directories }
- OpenDialog1.Options := [ofNoChangeDir];
- OpenDialog1.Title := 'Rename File';
- { If not cancelled then do rename or signal error }
- if OpenDialog1.Execute then
- begin
- ScrollBox1.TheFWB.RenameTheFile( CurrentName , OpenDialog1.Filename );
- end;
- end;
- end;
- if CurrentView = 1 then { Reset icon display if in view }
- ScrollBox1.Update else FileListBox1.Update; { Otherwise update the FLB }
- end;
-
- { Delphi wrote this; use it to make a new directory under current one }
- procedure TCCFileMgrForm.BitBtn5Click(Sender: TObject);
- begin
- { Set up the dialog to get the new directory name }
- OpenDialog2.FileName := '*.*';
- OpenDialog2.Title := 'Enter Directory Name';
- if OpenDialog1.Execute then
- begin
- { If not cancelled make new directory }
- Scrollbox1.TheFWB.CreateNewDirectory( OpenDialog1.Filename );
- end;
- if CurrentView = 1 then { Reset icon display if in view }
- ScrollBox1.Update else FileListBox1.Update; { Otherwise update the FLB }
- end;
-
- { Delphi wrote this; use it to display and set data from options dialog }
- { Delphi wrote this; use it to synchronize the display with the listboxes }
- procedure TCCFileMgrForm.DirectoryListBox1Change(Sender: TObject);
- begin
- { Set the display string to the uppercase of the current directory }
- Label1.Caption := UpperCase( DirectoryListBox1.Directory );
- end;
-
- { Delphi wrote this; use it to handle refreshing the scrollbox }
- procedure TCCFileMgrForm.FormPaint(Sender: TObject);
- var CurrentDirectory : String; { Get current dir }
- begin
- { If updated, do refresh }
- if ScrollBox1.IconsNeedRefreshing then
- begin
- Scrollbox1.Free;
- ScrollBox1 := TFileIconPanelScrollBox.Create( Panel1 );
- ScrollBox1.Parent := Panel1;
- ScrollBox1.align := alClient;
- ScrollBox1.Left := 0;
- ScrollBox1.Top := 0;
- ScrollBox1.Width := Panel1.Width - 32;
- ScrollBox1.Height := Panel1.Height - 32;
- ScrollBox1.IconsNeedRefreshing := false;
- ScrollBox1.TheStoredHandle := Self.Handle;
- GetDir( 0 , CurrentDirectory );
- { Force trailing backslash }
- CurrentDirectory := ScrollBox1.TheFWB.ForceTrailingBackSlash(
- CurrentDirectory );
- { Set the label to the new directory }
- Label1.Caption := UpperCase( CurrentDirectory );
- { Do the update }
- ScrollBox1.GetIconsForEntireDirectory( CurrentDirectory );
- end;
- end;
-
- { Delphi wrote this; use it to respond to dbl-clicking FLB filename }
- procedure TCCFileMgrForm.FileListBox1DblClick(Sender: TObject);
- begin
- { Call shellexec as a wrapper around ShellExecute API call }
- { False indicates failure, signal error }
- if not ShellExec( ExpandFileName( FileListbox1.Items[
- FileListBox1.ItemIndex ] ), '' , '', false , SW_SHOWNORMAL , false ) then
- MessageDlg('Could not Shell out to ' + FileListBox1.Items[
- FileListBox1.ItemIndex ] , mtError, [mbOK], 0);
- end;
-
- { Delphi wrote this; use it to reset the current view Icons/List }
- procedure TCCFileMgrForm.BitBtn8Click(Sender: TObject);
- var TheOldString : String; { Use to get current directory }
- begin
- { Reset currentview }
- if CurrentView = 1 then CurrentView := 2 else
- CurrentView := 1;
- { either show the windows boxes or the scrollbox }
- case CurrentView of
- 1 : begin
- { Make the listboxes invisible by changing align and width }
- FileListBox1.Visible := false;
- FileListBox1.Align := alNone;
- FileListBox1.Width := 0;
- DirectoryListBox1.Visible := false;
- DirectoryListBox1.align := alNone;
- DirectoryListBox1.Width := 0;
- { Keep them from getting mouse clicks }
- FileListBox1.Enabled := false;
- DirectoryListBox1.Enabled := false;
- { Have the scrollbox get mouse and be seen by resetting align/wid}
- Scrollbox1.align := alClient;
- Scrollbox1.width := Panel1.Width - 32;
- ScrollBox1.Enabled := true;
- { Tell the scrollbox to repaint itself just in case }
- ScrollBox1.Update;
- end;
- 2 : begin
- { Make the listboxes visible by resetting align and width}
- FileListBox1.Visible := true;
- DirectoryListBox1.Visible := true;
- DirectoryListBox1.width := 145;
- DirectoryListBox1.align := alLeft;
- FileListBox1.align := alClient;
- FileListBox1.Width := Panel1.Width - 32 - DirectoryListBox1.Width;
- { Have them getting mouse clicks }
- FileListBox1.Enabled := true;
- DirectoryListBox1.Enabled := true;
- { Have the scrollbox not get mouse and not be seen via align/width}
- ScrollBox1.Enabled := false;
- ScrollBox1.Visible := false;
- ScrollBox1.align := alNone;
- ScrollBox1.Width := 0;
- end;
- end;
- Invalidate;
- end;
-
- { Delphi wrote this; use it to do a file search display }
- procedure TCCFileMgrForm.BitBtn9Click(Sender: TObject);
- var CurrentDirectory : String; { Holds current directory }
- begin
- { Set up and run the search dialog }
- OpenDialog2.FileName := '*.*';
- { if not cancelled do the search }
- if OpenDialog2.Execute then
- begin
- { Get current directory }
- GetDir( 0 , CurrentDirectory );
- { Force trailing backslash }
- CurrentDirectory :=
- ScrollBox1.TheFWB.ForceTrailingBackSlash( CurrentDirectory );
- { display recursive search results }
- Scrollbox1.DisplayRecursiveSearchResults(
- CurrentDirectory + OpenDialog2.Filename );
- Label1.Caption := 'Search Results for ' + CurrentDirectory +
- OpenDialog2.FileName;
- end;
- end;
-
- end.
-